const { defineConfig } = require("@vue/cli-service");
const path = require('path');


console.log(process.env)
function resolve (dir) {
  console.log(path.join(dir))
    return path.join (dir)
}
module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave: false,
  devServer:{
    // 配置启动服务器得端口号
    port:parseInt(process.env.VUE_APP_PORT),
    proxy:{
      "/api":{
        // 目标服务器
        target:process.env.VUE_APP_BASE_URL,
        // 路径重写
        pathRewrite:{
          "^/api":""
        }
      }
    }
    
  },
  chainWebpack: (config)=>{
    config.resolve.alias
    // 别名配置
        .set('&', resolve('src'))
        .set('assets',resolve('src/assets'))
        .set('components',resolve('src/components'))
        .set('layout',resolve('src/layout'))
        .set('base',resolve('src/base'))
        .set('static',resolve('src/static'))

        //设置打包hash
        config.output
        .filename(
          `assets/js/[name].${process.env.VUE_APP_VERSION}.${+new Date()}.js`
        )
        .chunkFilename(
          `assets/js/[name].${process.env.VUE_APP_VERSION}.${+new Date()}.js`
        )
        .end();
  }
});
 